﻿@using DotNet.Framework.Admin.Entity.EDNFramework_Repairs;
@{
    ViewBag.Title = "订单明细";
    var order = ViewBag.order as Entity_Order;
    var histories = ViewBag.histories as List<Entity_Order_History>;
    var contact = ViewBag.contact as Entity_Order_ContactsAddress;
}

<div class="widget-content">
    <ul class="nav nav-tabs">
        <li class="active"><a href="#info" data-toggle="tab">订单信息</a></li>
        <li><a href="#seo" data-toggle="tab">订单进度</a></li>
        <li><a href="#Contact" data-toggle="tab">联系信息</a></li>
    </ul>
    <br />
    <div class="tab-content">
        <div class="tab-pane active form-horizontal" id="info">
            <fieldset>
                <table class="table table-striped table-bordered table-hover">
                    <tr>

                        <td style="width: 90px;">订单编号：</td>
                        <td>@order.ID</td>
                    </tr>
                    <tr>

                        <td>内部编号：</td>
                        <td>@order.OrderNumber</td>
                    </tr>
                    <tr>

                        <td>客户：</td>
                        <td>@order.UserName</td>
                    </tr>
                    <tr>

                        <td>电脑类型：</td>
                        <td>
                            @switch (order.Statu)
                            {
                                case 0:
                                <text>订单创建</text>
                                    break;
                                case 1:
                                <text>系统确认</text>
                                    break;
                                case 2:
                                <text>已派单</text>
                                    break;
                                case 3:
                                <text>工作完成</text>
                                    break;
                                case 4:
                                <text>订单完成</text>
                                    break;
                                case 5:
                                <text>订单关闭</text>
                                    break;
                                case -1:
                                <text>系统删除</text>
                                    break;
                            }
                        </td>
                    </tr>
                    <tr>

                        <td>电脑品牌：</td>
                        <td>@order.BrandName</td>
                    </tr>
                    <tr>

                        <td>电脑型号：</td>
                        <td>@order.Model</td>
                    </tr>
                    <tr>

                        <td>故障描述：</td>
                        <td>@order.RepairsDescription</td>
                    </tr>
                    <tr>

                        <td>订单状态：</td>
                        <td>@switch (order.Statu)
                            {
                                case 0:
                            <text>订单创建</text>
                                    break;
                                case 1:
                            <text>系统确认</text>
                                    break;
                                case 2:
                            <text>已经分派</text>
                                    break;
                                case 3:
                            <text>工作完成</text>
                                    break;
                                case 4:
                            <text>订单完成</text>
                                    break;
                                case 5:
                            <text>关闭</text>
                                    break;
                                case -1:
                            <text>删除</text>
                                    break;
                                default: 
                            <text>不详</text>
                                    break;
                            }

                            @if (order.Statu == 2)
                            {
                                <text>（</text>@order.ModifyTime<text>）-</text> @order.AssignedToUser
                            }
                        </td>
                    </tr>
                    <tr>

                        <td>备注信息：</td>
                        <td>@order.Remark</td>
                    </tr>

                </table>
            </fieldset>
        </div>
        <div class="tab-pane form-horizontal" id="seo">
            <fieldset>

                <table class="table table-striped table-bordered table-hover">
                    @if (histories.Count() <= 0)
                    {
                        <tr>
                            <td>该订单暂无进度</td>
                        </tr>
                    }
                    else
                    {
                        foreach (var item in histories)
                        {
                        <tr>
                            <td style="width: 150px;">@item.CreateTime</td>
                            <td>@item.Note</td>
                        </tr>
                        }
                    }
                </table>
            </fieldset>
        </div>
        <div class="tab-pane form-horizontal" id="Contact">
            <fieldset>
                <table class="table table-striped table-bordered table-hover">
                    <tr>
                        <td style="width: 90px;">联系人：</td>
                        <td>@contact.ContactsName</td>
                    </tr>
                    <tr>

                        <td>联系电话：</td>
                        <td>@contact.ContactsMobile</td>
                    </tr>
                    <tr>

                        <td>联系地址：</td>
                        <td>@contact.ContactsAddress</td>
                    </tr>

                </table>

            </fieldset>
        </div>
    </div>
</div>

@if (order.Statu == 2)
{
    <div class="bs-example bs-example-standalone">
        <div role="alert" class="alert alert-info alert-dismissible fade in">
            @using (Ajax.BeginForm("SetOrderCompleted", "home", null, new AjaxOptions() { OnFailure = "OnFailure", OnSuccess = "OnSuccess", HttpMethod = "POST", Confirm = "确认完成后订单将会自动关闭，是否继续？" }))
            {
                <input type="hidden" name="id" value="@order.ID" />
                <input type="hidden" name="status" value="3" />
                <h4>提示!</h4>
                <p>如果您已经处理完成此订单，请点击处理完成。</p>
                
                <p>
                    <input class="btn btn-default" type="submit" value="处理完成" />
                </p>
                
            }
        </div>
    </div>
}
@section scripts{
    <script type="text/javascript">
        function OnSuccess(data) {
            if (data) {
                if (data.status == 1) {
                    window.location.reload();
                }
            }
        }

    </script>
}